<?php


namespace app\admin\system\controller;


use app\admin\system\logic\AreaLogic;
use app\common\controller\BaseAdminController;
use support\utils\TreeUtil;

class AreaController extends BaseAdminController
{
    protected function init()
    {
        parent::init();
        $this->logic = new AreaLogic();
    }

    public function getArea()
    {
        $parent_code = input('parent_code', "000000");

        return $this->success($this->logic->getList([
            'parent_code' => $parent_code
        ]));
    }

    public function getAreaTree()
    {
        $data = $this->logic->getList([
            'type' => [1, 2]
        ]);
        $data = TreeUtil::getTree($data, 'parent_code', 'code');
        return $this->success($data);
    }
}